package com.zhuhjay.servicebase.handler;

import com.zhuhjay.commonutils.R;
import com.zhuhjay.servicebase.exception.GuLiException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author ZhuHJay
 * @date 2022/9/6 12:20
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler({Exception.class})
    public R handler(Exception e) {
        return R.error().message(e.getMessage());
    }

    @ExceptionHandler({GuLiException.class})
    public R handler(GuLiException e) {
        return R.error().message(e.getMsg());
    }

}
